import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2024-01-27
 * Time:16:30
 */
public class Main {
    public static void main1(String[] args) {
//        String str1 = "abc";
//        String str2 = "aecd";
//        String str3 = "aecdefg";
//        System.out.println(str1.compareTo(str2)); //b和eASCII码相差3，输出-3（因为b小于e）
//        System.out.println(str2.compareTo(str3)); //str3比str2长，且前4个字符相同，此时返回二者长度差值
//        System.out.println(str1.equals(str2));//输出true
//        System.out.println(str3.equals(str1));//输出false
        String s1 = String.valueOf(1234);
        String s2 = String.valueOf(12.34);
        String s3 = String.valueOf(true);
        String s4 = String.valueOf(new Student("砂糖橘",100));
        System.out.println(s1);
        System.out.println(s2);
        System.out.println(s3);
        System.out.println(s4);
    }

    public static void main2(String[] args) {
        String s = "hello";
        // 字符串转数组
        char[] ch = s.toCharArray();
        System.out.println(Arrays.toString(ch));
    }

    public static void main3(String[] args) {
        String s1 = String.format("%d-%d-%d", 2024, 1,27);
        String s2 = "乌蒙山";
        String s3 = String.format("%s连着山外山",s2);
        System.out.println(s1);
        System.out.println(s3);
    }

    public static void main(String[] args) {
        String s1 = "hello world";
        String  s2 = s1.replaceAll("l","a");
        System.out.println(s2);
        String  s3 = s1.replaceFirst("l","a");
        System.out.println(s3);
    }
}
